﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LearnCSharp_1
{
    class LearnCollection
    {
        static void Main_Collection(string[] args)
        {
            var names = new List<string> { "<name>", "Ana", "Felipe" };
            foreach (var name in names)
            {
                Console.WriteLine($"Hello {name.ToUpper()}");
            }
            Console.WriteLine($"My name is {names[0]}.");
            Console.WriteLine($"I've added {names[1]} and {names[2]} to the list.");
            Console.WriteLine($"The list has {names.Count} people in it.");
            Console.ReadKey();

            var index = names.IndexOf("Felipe");
            if (index != -1)
                Console.WriteLine($"The name {names[index]} is at index {index}");
            var notFound = names.IndexOf("Not Found");
            Console.WriteLine($"When an item is not found, IndexOf returns {notFound}");

            names.Sort();
            foreach (var name in names)
            {
                Console.WriteLine($"Hello {name.ToUpper()}!");
            }
            Console.ReadKey();

            var fibonacciNumbers = new List<int> { 1, 1 };
            var previous = fibonacciNumbers[fibonacciNumbers.Count - 1];
            var previous2 = fibonacciNumbers[fibonacciNumbers.Count - 2];
            fibonacciNumbers.Add(previous + previous2);
            foreach (var item in fibonacciNumbers)
                Console.WriteLine(item);
            Console.ReadKey();


        }

        public static void test_array_list()
        {
            ArrayList arrayList = new ArrayList();
            arrayList.Add(123);
            arrayList.Add("abc");
            arrayList.Insert(1, 123 + "abc");
            arrayList.RemoveAt(1);

        }

        public static void test_dictionary()
        {
            Dictionary<int, string> dictionary = new Dictionary<int, string>();
            dictionary.Add(1, "98");

        }
    }
}
